#define _CRT_SECURE_NO_WARNINGS
#include"Linked_list.h"

void Test_LinkedList_one()
{
	LinkedListNode* phead = NULL;
	LinkedListPushBack(&phead, 1);
	LinkedListPushBack(&phead, 2);
	LinkedListPushBack(&phead, 3);
	LinkedListPushBack(&phead, 4);
	LinkedListPushBack(&phead, 5);
	LinkedListPrint(phead);

	LinkedListPopBack(&phead);
	LinkedListPrint(phead);

	LinkedListPopBack(&phead);
	LinkedListPrint(phead);

	LinkedListPopBack(&phead);
	LinkedListPrint(phead);

	LinkedListPopBack(&phead);
	LinkedListPrint(phead);

	LinkedListPopBack(&phead);
	LinkedListPrint(phead);
}

void Test_LinkedList_two()
{
	LinkedListNode* phead = NULL;
	LinkedListPushFront(&phead, 1);
	LinkedListPushFront(&phead, 2);
	LinkedListPushFront(&phead, 3);
	LinkedListPushFront(&phead, 4);
	LinkedListPushFront(&phead, 5);	
	LinkedListPrint(phead);

	LinkedListPopFront(&phead);
	LinkedListPrint(phead);

	LinkedListPopFront(&phead);
	LinkedListPrint(phead);

	LinkedListPopFront(&phead);
	LinkedListPrint(phead);

	LinkedListPopFront(&phead);
	LinkedListPrint(phead);

	LinkedListPopFront(&phead);
	LinkedListPrint(phead);
}

void Test_LinkedList_three()
{
	LinkedListNode* phead = NULL;
	LinkedListPushBack(&phead, 1);
	LinkedListPushBack(&phead, 2);
	LinkedListPushBack(&phead, 3);
	LinkedListPushBack(&phead, 4);
	LinkedListPushBack(&phead, 5);
	LinkedListPrint(phead);

	LinkedListNode* p1 = LinkedListFind(phead, 1);
	printf("%p\n", p1);
	LinkedListNode* p2 = LinkedListFind(phead, 2);
	printf("%p\n", p2);
	LinkedListNode* p3 = LinkedListFind(phead, 3);
	printf("%p\n", p3);
	LinkedListNode* p4 = LinkedListFind(phead, 4);
	printf("%p\n", p4);
	LinkedListNode* p5 = LinkedListFind(phead, 5);
	printf("%p\n", p5);
}

void Test_LinkedList_four()
{
	LinkedListNode* phead = NULL;
	LinkedListPushBack(&phead, 1);
	LinkedListPushBack(&phead, 2);
	LinkedListPushBack(&phead, 3);
	LinkedListPushBack(&phead, 4);
	LinkedListPushBack(&phead, 5);
	LinkedListPrint(phead);

	LinkedListNode* p1 = LinkedListFind(phead, 1);
	LinkedListInsert(&phead, p1, 9);
	LinkedListNode* p2 = LinkedListFind(phead, 2);
	LinkedListInsert(&phead, p2, 8);
	LinkedListNode* p3 = LinkedListFind(phead, 3);
	LinkedListInsert(&phead, p3, 7);
	LinkedListNode* p4 = LinkedListFind(phead, 4);
	LinkedListInsert(&phead, p4, 6);
	LinkedListNode* p5 = LinkedListFind(phead, 5);
	LinkedListInsert(&phead, p5, 5);
	LinkedListPrint(phead);
}

void Test_LinkedList_five()
{
	LinkedListNode* phead = NULL;
	LinkedListPushBack(&phead, 1);
	LinkedListPushBack(&phead, 2);
	LinkedListPushBack(&phead, 3);
	LinkedListPushBack(&phead, 4);
	LinkedListPushBack(&phead, 5);
	LinkedListPrint(phead);

	LinkedListNode* p1 = LinkedListFind(phead, 1);
	LinkedListInsert(&phead, p1, 9);
	LinkedListNode* p2 = LinkedListFind(phead, 2);
	LinkedListInsert(&phead, p2, 8);
	LinkedListNode* p3 = LinkedListFind(phead, 3);
	LinkedListInsert(&phead, p3, 7);
	LinkedListNode* p4 = LinkedListFind(phead, 4);
	LinkedListInsert(&phead, p4, 6);
	LinkedListNode* p5 = LinkedListFind(phead, 5);
	LinkedListInsert(&phead, p5, 5);
	
	LinkedListErase(&phead, p1);
	LinkedListErase(&phead, p2);
	LinkedListErase(&phead, p3);
	LinkedListErase(&phead, p4);
	LinkedListErase(&phead, p5);
	LinkedListPrint(phead);
}

int main()
{
	Test_LinkedList_one();
	Test_LinkedList_two();
	Test_LinkedList_three();
	Test_LinkedList_four();
	Test_LinkedList_five();

	return 0;
}